<?php
$upload_dir = "/var/www/html/test/upload";
$attachment = $_FILES['Filedata'];
$filename = $attachment['name'];
$fileext = substr(strrchr($filename,'.'),1);

$path = $upload_dir."/".my_rand(15).".".$fileext;
move_uploaded_file($attachment['tmp_name'],$path);

function my_rand($length){
  $chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890";
  $end = strlen($chars)-1;
  for($i=0;$i<$length;$i++){
        $hash .= $chars[mt_rand(0,$end)];
  }
  return $hash;
}
?>